home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
linuxcon.000
/
linuxcon
/
linuxconf-1.6
/
userconf
/
userconf.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-21
|
4KB
|
181 lines
#pragma interface
#ifndef USERCONF_H
#define USERCONF_H
struct passwd;
struct group;
class USER;
class USERS;
class GROUPS;
class SHADOW;
class DIALOG;
#include "../misc/misc.h"
class PRIVILEGE_DATA: public ARRAY_OBJ{
protected:
char active;
char authenticate;
public:
virtual void setdialog(DIALOG &dia)=0;
virtual int validate()=0;
virtual void format_ascii(char *line)=0;
/*~PROTOBEG~ PRIVILEGE_DATA */
/*~PROTOEND~ PRIVILEGE_DATA */
};
class PRIVILEGE{
SSTRING id; // Name of the priviledge
PRIVILEGE *next;
/*~PROTOBEG~ PRIVILEGE */
public:
PRIVILEGE (const char *_id);
virtual PRIVILEGE_DATA *getdata (const char *line);
/*~PROTOEND~ PRIVILEGE */
};
class USER: public ARRAY_OBJ{
SSTRING name;
SSTRING passwd;
int uid;
int gid;
SSTRING comment;
SSTRING wrkdir;
SSTRING shell;
int special; // Special user accounts like uucp and slip
// Whatever is using a shell for non human.
/*~PROTOBEG~ USER */
public:
USER (const char *_name,
const char *_passwd,
int _uid,
int _gid,
const char *_gecos,
const char *_dir,
const char *_shell);
USER (const char *line);
USER (struct passwd *p);
USER (void);
private:
int check (USERS&users, GROUPS&groups, int full);
public:
int checkhome (char *status);
int edit (USERS&users, GROUPS&groups, int is_new);
int edithispass (SHADOW *shadow);
int edithispass_notty (SHADOW *shadow);
int editpass (int lock_available, SHADOW *shadow);
const char *getgecos (void);
int getgid (void);
const char *getname (void);
const char *getpwd (void);
const char *getshell (void);
int getuid (void);
private:
void init (const char *_name,
const char *_passwd,
int _uid,
int _gid,
const char *_gecos,
const char *_dir,
const char *_shell);
public:
int is_admin (void);
int is_like (USER *other);
int is_special (void);
int sethome (void);
void setlike (USER *other);
void setname (const char *_name);
private:
void update_passwd (const char *newp,
SHADOW *shadow,
int is_lock);
public:
void write (FILE *fout);
~USER (void);
/*~PROTOEND~ USER */
};
class USERS: public ARRAY{
class SHADOWS *shadows;
/*~PROTOBEG~ USERS */
public:
USERS (void);
int addone (USER *special,
const char *name,
GROUPS&groups);
void addshadow (SHADOW *shadow);
int edit (USER *special);
int editpass (USER *special);
USER *getfromuid (int uid);
USER *getitem (const char *name);
USER *getitem (int no);
int getnewuid (int gid);
SHADOW *getshadow (USER *usr);
USER *select (USER *like,
int may_add,
MENU_STATUS&code,
int &choice);
void sortbygid (void);
void sortbyname (void);
int write (void);
~USERS (void);
/*~PROTOEND~ USERS */
};
class GROUP: public ARRAY_OBJ{
SSTRING name;
SSTRING passwd;
int gid;
SSTRINGS tbmem; // User member of this group (not their primary group)
/*~PROTOBEG~ GROUP */
public:
GROUP (const char *_name,
const char *_passwd,
int _gid,
char **members);
GROUP (struct group *p);
GROUP (void);
private:
int check (USERS&users,
GROUPS&groups,
GROUP *realone);
public:
int edit (USERS&users, GROUPS&groups);
int getgid (void);
const char *getname (void);
private:
void init (const char *_name,
const char *_passwd,
int _gid,
char **members);
void settbmem (char **members);
public:
void write (FILE *fout);
~GROUP (void);
/*~PROTOEND~ GROUP */
};
class GROUPS: public ARRAY{
/*~PROTOBEG~ GROUPS */
public:
GROUPS (void);
int edit (void);
const char *getdefault (void);
GROUP *getfromgid (int gid);
int getgid (const char *name);
GROUP *getitem (const char *name);
GROUP *getitem (int no);
int getnew (void);
void sortbyname (void);
int write (void);
~GROUPS (void);
/*~PROTOEND~ GROUPS */
};
#include "userconf.p"
#endif